package com.hr;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Transient;

import com.espirit.common.Form;
import com.espirit.eap.annotation.Dict;
import com.espirit.eap.annotation.DomainModel;
import com.espirit.finance.core.AcctTerm;
import com.espirit.finance.core.AcctTermCheckAware;

@Entity
@DomainModel
public class OtItem extends Form implements  AcctTermCheckAware{
	private static final long serialVersionUID = 3111184631633344501L;
	public static final String OT_TYPE="otitem_type";
	public static final Integer OT_TYPE_PAY = 1;
	public static final Integer OT_TYPE_EXCHANGING = 2;
	
	
	public BigDecimal getHours() {
		return hours;
	}
	public void setHours(BigDecimal hours) {
		this.hours = hours;
	}

	

	public Date getRealTime() {
		return realTime;
	}
	public void setRealTime(Date realTime) {
		this.realTime = realTime;
	}
	
	@Dict(type=OT_TYPE)
	public Integer getOtType() {
		return otType;
	}
	public void setOtType(Integer otType) {
		this.otType = otType;
	}
	
	
	
	@Override
	public boolean check(AcctTerm acctTerm) {
		if (acctTerm != null && acctTerm.getBeginDate() != null && this.realTime != null){
			return acctTerm.getBeginDate().compareTo(this.realTime) < 0;
		} else {
			return true;
		}
	}
	
	private Date realTime;
	private BigDecimal hours;
	
	private Integer otType;
	
	
	@Override
	@Transient
	public boolean isAccept() {
		return false;
	}


	@Override
	public void onWFStarted() {
		
	}

	@Override
	public void onWFAccept() {
		
	}

	@Override
	public void onWFReject() {
		
	}
}
